//package com.plian.system.service.zzd.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.plian.Tools.CollectionUtil;
//import com.plian.Tools.DateUtil;
//import com.plian.system.constant.sys.FormStatusConstant;
//import com.plian.system.dto.zzd.ZZDQuery;
//import com.plian.system.entity.hr.staff.StaffFiles;
//import com.plian.system.entity.sys.Org;
//import com.plian.system.service.hr.staff.IStaffFilesService;
//import com.plian.system.service.sys.orgzation.IOrgService;
//import com.plian.system.service.zzd.IZZDPartyBuildService;
//import com.plian.system.vo.zzd.partybuild.PartyBuildVO;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * @Description: TODO
// * @Author: Take-off
// * @Date: 2023/3/15 5:04 PM
// * @Param
// * @return
// * @Version: 1.0
// **/
//@Slf4j
//@Service
//@AllArgsConstructor
//public class ZZDPartyBuildServiceImpl implements IZZDPartyBuildService {
////    //党建组织地图
////    private final IDjPartyOrganizationMapService partyOrganizationMapService;
////
////    //党员基本信息
////    private final IDjPartymemberBaseinfoService partymemberBaseinfoService;
//
//    private final IStaffFilesService staffFilesService;
//
//    private final IOrgService orgService;
//
//    @Override
//    public PartyBuildVO getPartyBuild(ZZDQuery query) {
//        PartyBuildVO partyBuildVO = PartyBuildVO.builder().partyMember(0).staffTotal(0).partyOrganization(0).build();
//        //组织Id
//        List<String> orgIds = new ArrayList<>();
//        if (query.getOrgType() == 1) {
//            //全大市
//            orgIds = orgService.getAllOrg().stream().map(Org::getId).collect(Collectors.toList());
//        } else {
//            //监管企业
//            orgIds = orgService.getGzwUnits(orgService.getDTFlag(query.getReportTime())).stream().map(Org::getId).collect(Collectors.toList());
//        }
//        //党组织数
//        Date reportDate = DateUtil.parse(query.getReportTime(), DateUtil.PATTERN_MONTH);
//        List<DjPartyOrganizationMap> partyOrganizationMaps = partyOrganizationMapService.list(new LambdaQueryWrapper<DjPartyOrganizationMap>().eq(DjPartyOrganizationMap::getStatus, FormStatusConstant.FINISH)
//                .le(DjPartyOrganizationMap::getCreateTime, DateUtil.plusMonths(reportDate, 1)));
//        if (CollectionUtil.isNotEmpty(partyOrganizationMaps)){
//            partyBuildVO.setPartyOrganization(partyOrganizationMaps.size());
//        }
//        //党员数
//        List<DjPartymemberBaseInfo> djPartymemberBaseInfos = partymemberBaseinfoService.list(new LambdaQueryWrapper<DjPartymemberBaseInfo>().in(DjPartymemberBaseInfo::getFillingUnitId, orgIds).eq(DjPartymemberBaseInfo::getStatus, FormStatusConstant.FINISH)
//                .le(DjPartymemberBaseInfo::getCreateTime, DateUtil.plusMonths(reportDate, 1)));
//        if (CollectionUtil.isNotEmpty(djPartymemberBaseInfos)){
//            Integer reduce = djPartymemberBaseInfos.stream().map(DjPartymemberBaseInfo::getPeopleNum).reduce(0, Integer::sum);
//            partyBuildVO.setPartyMember(reduce);
//        }
//        //职工总人数
//        List<StaffFiles> staffFiles = staffFilesService.list(new LambdaQueryWrapper<StaffFiles>().in(StaffFiles::getCreateCompanyId, orgIds));
//        if (CollectionUtil.isNotEmpty(staffFiles)){
//            partyBuildVO.setStaffTotal(staffFiles.size());
//        }
//        return partyBuildVO;
//
//    }
//}
